package com.mmall.concurrency.example.singleton;

import com.mmall.concurrency.annoations.Recommend;
import com.mmall.concurrency.annoations.ThreadSafe;

@ThreadSafe
@Recommend
public class SingletonExample7 {
    private SingletonExample7() {
    }

    public static SingletonExample7 getInstance() {
        return Singleton.SINGLETON.getInstance();
    }

    private enum Singleton {
        SINGLETON;
        private SingletonExample7 singletonExample7;
        //jvm保证真个方法绝对只调用一次
        Singleton() {
            singletonExample7 = new SingletonExample7();
        }

        public SingletonExample7 getInstance() {
            return singletonExample7;
        }

    }


}
